import React, { Suspense, lazy } from "react";
import {BrowserRouter as Router, Route, Switch} from "react-router-dom";


import App from "@src/App";
// import Home from "@src/pages/Home/index";
// import Admin from "@src/pages/Admin/index";
// 动态路由
const LazyHome = lazy(()=> import("@src/pages/Home/index"));
const LazyAdmin = lazy(()=> import("@src/pages/Admin/index"));
const LazyTic = lazy(()=> import("@src/pages/Tic/index"));
// import() example: import( /* webpackChunkName: "AsyncHome" */ "@src/pages/Home/index")
// console.log( lazyHome );

const BasicRoute = () => (
    <Router>
        <Suspense fallback={<div></div>}>
            <Switch>
                <Route exact path="/" component={App}></Route>
                <Route path="/home" component={(props)=> <LazyHome {...props} />}></Route>
                <Route path="/admin" component={(props)=> <LazyAdmin {...props} />}></Route>
                <Route path="/tic" component={(props)=> <LazyTic {...props} />}></Route>
            </Switch>
        </Suspense>
    </Router>
);

export default BasicRoute;
